package 预科0104UserMessage_Q4;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;

import 预科0104UserMessage_Q4.UserMessage.User;

public class UserMessageClient {
	public static void main(String[] args) {
		Socket sc=null;
		try {
			UserMessage um1=new UserMessage("check",new User("admin","123456"));
			sc=new Socket("127.0.0.1",8888);
			ObjectOutputStream oo=new ObjectOutputStream(sc.getOutputStream());
			oo.writeObject(um1);
			ObjectInputStream oi = new ObjectInputStream(sc.getInputStream());
			um1=(UserMessage)oi.readObject();
			System.out.println(um1.getType().equals("success")?"登录成功":"登录失败");
		} catch (IOException | ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				sc.close();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
	}
	
}
 